/**
 * @controller 工时管理
 * @description 工时管理
 * @version: 0.0.1
 * @author: ljr
 * @Date: 2023-09-12 16:35:58
 */

import { Inject, Controller, Body, Post, Get, Query } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
import { UserRoleService } from '../service/user.role.service';
import { UpdateDTO, CreatedDTO } from '../dto/user.role';
import { IdDTO, Page2DTO } from "../dto/common"

@Controller('/api/v1/user/role')
export class userRoleController {
  @Inject()
  ctx: Context;
  @Inject()
  UserRoleService: UserRoleService;

  /**
   * @summary 新增角色
   * @description 新增角色
   * @router post /api/v1/user/role/create
   * @request body roleName  *body
   * @request body roleCode  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/create')
  async createdUserRole(@Body() options: CreatedDTO): Promise<any> {
    return await this.UserRoleService.createdUserRole(options);
  }


  /**
   * @summary 获取角色列表
   * @description 获取角色列表
   * @router post /api/v1/user/role/getList
   * @request body pageNum  *body
   * @request body pageSize  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/getList')
  async getWorkingPage(@Body() options: Page2DTO): Promise<any> {
    return await this.UserRoleService.getUserRoleList(options);
  }

  /**
   * @summary 更新角色
   * @description 更新角色
   * @router post /api/v1/user/role/update
   * @request body id  *body
   * @request body roleName  *body
   * @request body roleCode  *body
   * @response 200 baseResponse 返回结果
   */
  @Post('/update')
  async updateUserRole(@Body() options: UpdateDTO): Promise<any> {
    return await this.UserRoleService.updateUserRole(options);
  }

  /**
   * @summary 删除角色
   * @description 删除角色
   * @router post /api/v1/user/role/del
   * @request body id  *body
   * @request body roleName  *body
   * @request body roleCode  *body
   * @response 200 baseResponse 返回结果
   */
  @Get('/del')
  async delUserRole(@Query() options: IdDTO): Promise<any> {
    return await this.UserRoleService.delUserRole(options.id);
  }
 
}